package io.renren.wechat.service.impl;

import com.alibaba.druid.util.StringUtils;
import io.renren.wechat.entity.ChatMsgEntity;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.wechat.dao.FriendsRequestDao;
import io.renren.wechat.entity.FriendsRequestEntity;
import io.renren.wechat.service.FriendsRequestService;


@Service("friendsRequestService")
public class FriendsRequestServiceImpl extends ServiceImpl<FriendsRequestDao, FriendsRequestEntity> implements FriendsRequestService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
//        IPage<FriendsRequestEntity> page = this.page(
//                new Query<FriendsRequestEntity>().getPage(params),
//                new QueryWrapper<FriendsRequestEntity>()
//        );
//
//        return new PageUtils(page);
//    }

        QueryWrapper<FriendsRequestEntity> wrapper = new QueryWrapper<>();
        String key = (String) params.get("key");
        if (!StringUtils.isEmpty(key)){
            wrapper.eq("id",key)
                    .or().eq("send_user_id",key)
                    .or().eq("accept_user_id",key)
            ;
        }
        IPage<FriendsRequestEntity> page = this.page(
                new Query<FriendsRequestEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }
//2102056GTZB8CXS8   21033103KTN0GKGC

}